tests: Merge installed/ and fedora-str/ directories
authorColin Walters <walters@verbum.org>
Thu, 22 Mar 2018 20:40:35 +0000 (16:40 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 5 Apr 2018 20:59:23 +0000 (20:59 +0000)
Let's be opinionated now, and our installed/ test story *is*
Ansible/STR.  Merge `tests/fedora-str` into `tests/installed/`.

Rework the nondestructive tests into a separate playbook run, and parallelize
them for more efficiency.

The destructive tests are also changed to use Ansible more.

Add a higher level `run.sh` entrypoint and update the `README.md`
with some useful tips.

Closes: #1513
Approved by: jlebon

38 files changed:
.papr.yml
ci/fah27-insttests.sh [new file with mode: 0755]
tests/fedora-str/README.md [deleted file]
tests/fedora-str/overlay-git.yml [deleted file]
tests/fedora-str/playbook-run.sh [deleted file]
tests/fedora-str/provision.sh [deleted file]
tests/fedora-str/sysinstall-tests.yml [deleted file]
tests/installed/README.md
tests/installed/destructive.yml [new file with mode: 0644]
tests/installed/destructive/README.md [new file with mode: 0644]
tests/installed/destructive/itest-bare-root.sh [new file with mode: 0755]
tests/installed/destructive/itest-deploy-selinux.sh [new file with mode: 0755]
tests/installed/destructive/itest-label-selinux.sh [new file with mode: 0755]
tests/installed/execute_batch.yml [new file with mode: 0644]
tests/installed/itest-bare-root.sh [deleted file]
tests/installed/itest-bare-unit.sh [deleted file]
tests/installed/itest-bare-user-root.sh [deleted file]
tests/installed/itest-bareuser-nouserxattrs.sh [deleted file]
tests/installed/itest-deploy-selinux.sh [deleted file]
tests/installed/itest-label-selinux.sh [deleted file]
tests/installed/itest-payload-link.sh [deleted file]
tests/installed/itest-pull-space.sh [deleted file]
tests/installed/itest-pull.sh [deleted file]
tests/installed/itest-remotes.sh [deleted file]
tests/installed/libinsttest.sh
tests/installed/nondestructive.yml [new file with mode: 0644]
tests/installed/nondestructive/itest-bare-unit.sh [new file with mode: 0755]
tests/installed/nondestructive/itest-bare-user-root.sh [new file with mode: 0755]
tests/installed/nondestructive/itest-bareuser-nouserxattrs.sh [new file with mode: 0755]
tests/installed/nondestructive/itest-payload-link.sh [new file with mode: 0755]
tests/installed/nondestructive/itest-pull-space.sh [new file with mode: 0755]
tests/installed/nondestructive/itest-pull.sh [new file with mode: 0755]
tests/installed/nondestructive/itest-remotes.sh [new file with mode: 0755]
tests/installed/nondestructive/libtest-core.sh [new symlink]
tests/installed/overlay-git.yml [new file with mode: 0644]
tests/installed/playbook-run.sh [new file with mode: 0755]
tests/installed/provision.sh [new file with mode: 0755]
tests/installed/run.sh

index 501aeecff5db1ab87b89f604a69fa711bdd8e60b..7f1e2e4942ddc376584612701aab484855b065ea 100644 (file)
--- a/.papr.yml
+++ b/.papr.yml
@@ -7,24 +7,29 @@ branches:
 context: FAH27-insttests
 required: true
 
-container:
-  image: registry.fedoraproject.org/fedora:27
+# FIXME; temporary workaround
+# https://github.com/ostreedev/ostree/pull/1513#issuecomment-378784162
+host:
+  distro: fedora/27/atomic
+  specs:
+    ram: 4096
+#container:
+#  image: registry.fedoraproject.org/fedora:27
 
 tests:
-  - cd tests/fedora-str && ../../ci/build-rpm.sh
-  - ./tests/fedora-str/provision.sh
-  # TODO: enhance papr to have caching, a bit like https://docs.travis-ci.com/user/caching/
-  - curl -Lo fedora-atomic-host.qcow2 https://getfedora.org/atomic_qcow2_latest
-  - env "TEST_SUBJECTS=$(pwd)/fedora-atomic-host.qcow2" ./tests/fedora-str/playbook-run.sh tests/fedora-str/sysinstall-tests.yml
+  - cd /etc/yum.repos.d/ && curl -L -O https://copr.fedorainfracloud.org/coprs/walters/oci-kvm-hook/repo/fedora-27/walters-oci-kvm-hook-fedora-27.repo
+  - rpm-ostree install oci-kvm-hook && rpm-ostree ex livefs
+  - docker run --device /dev/kvm --rm -v $(pwd):/srv/code:z registry.fedoraproject.org/fedora:27 /bin/sh -c "cd /srv/code && ./ci/fah27-insttests.sh"
 
 artifacts:
-  - tests/fedora-str/artifacts/fedora-atomic-host.qcow2.log
-  - tests/fedora-str/artifacts/installed-tests.log
+  - tests/installed/artifacts/
 
 ---
 
 # This suite skips the RPMs and does the build+unit tests in a container
-inherit: true
+inherit: false
+container:
+  image: registry.fedoraproject.org/fedora:27
 context: f27-primary
 env:
   # We only use -Werror=maybe-uninitialized here with a "fixed" toolchain
diff --git a/ci/fah27-insttests.sh b/ci/fah27-insttests.sh
new file mode 100755 (executable)
index 0000000..a045cf5
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/bash
+set -xeuo pipefail
+
+./tests/installed/provision.sh
+# TODO: enhance papr to have caching, a bit like https://docs.travis-ci.com/user/caching/
+cd tests/installed
+curl -Lo fedora-atomic-host.qcow2 https://getfedora.org/atomic_qcow2_latest
+exec env "TEST_SUBJECTS=$(pwd)/fedora-atomic-host.qcow2" ./run.sh
diff --git a/tests/fedora-str/README.md b/tests/fedora-str/README.md
deleted file mode 100644 (file)
index 8f21938..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This directory holds tests that use the
-[Fedora Standard Test Interface](https://fedoraproject.org/wiki/CI/Standard_Test_Interface).
diff --git a/tests/fedora-str/overlay-git.yml b/tests/fedora-str/overlay-git.yml
deleted file mode 100644 (file)
index 65fe937..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# Run "admin unlock" and add locally built RPMs, then
-# copy the whole tests/ directory into the VM.
-- command: ostree --version
-  changed_when: False
-  register: ostree_orig_version
-- set_fact:
-    ostree_orig_version_yaml: "{{ ostree_orig_version.stdout | from_yaml }}"
-- name: Copy locally built RPMs
-  synchronize: src=x86_64/ dest=/root/x86_64/ archive=yes
-- shell: ostree admin unlock || true
-# Install the RPMs we already have.  For the test suite we use rpm2cpio
-# since it depends on libsoup, but we're not using that yet for the sysinstalled tests
-- shell: >
-    /usr/bin/rpm -Fvh /root/x86_64/*.rpm && \
-    cd / && rpm2cpio /root/x86_64/ostree-tests-2*.rpm | cpio -div
-- command: ostree --version
-  register: ostree_new_version
-- set_fact:
-    ostree_new_version_yaml: "{{ ostree_new_version.stdout | from_yaml }}"
-- name: "Fail if we didn't change the ostree version"
-  when: ostree_orig_version_yaml['libostree']['Git'] == ostree_new_version_yaml['libostree']['Git']
-  fail:
-    msg: "Failed to change ostree version"
diff --git a/tests/fedora-str/playbook-run.sh b/tests/fedora-str/playbook-run.sh
deleted file mode 100755 (executable)
index 96e438d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/bash
-# A thin wrapper for ansible-playbook which has a nice check for
-# TEST_SUBJECTS being set.
-set -xeuo pipefail
-
-# https://fedoraproject.org/wiki/CI/Tests
-if test -z "${TEST_SUBJECTS:-}"; then
-    cat <<EOF
-
-error: TEST_SUBJECTS must be set; e.g.:
-
-  curl -Lo fedora-atomic-host.qcow2 'https://getfedora.org/atomic_qcow2_latest'
-  export TEST_SUBJECTS=\$(pwd)/fedora-atomic-host.qcow2
-
-If you're doing interactive development, we recommend caching the qcow2
-somewhere persistent.
-EOF
-    exit 1
-fi
-ls -al ${TEST_SUBJECTS}
-
-# This is required
-rpm -q standard-test-roles
-
-export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)}
-ls -al /dev/kvm
-exec ansible-playbook --tags=atomic "$@"
diff --git a/tests/fedora-str/provision.sh b/tests/fedora-str/provision.sh
deleted file mode 100755 (executable)
index b8ecdb4..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/bash
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/../../ci/libpaprci/libbuild.sh
-
-pkg_upgrade
-pkg_install git rsync openssh-clients ansible standard-test-roles
diff --git a/tests/fedora-str/sysinstall-tests.yml b/tests/fedora-str/sysinstall-tests.yml
deleted file mode 100644 (file)
index 58f216a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# This entrypoint right now just runs the sysinstalled-tests.
----
-- hosts: localhost
-  tags:
-  - atomic
-  remote_user: root
-  vars:
-    use_git_build: True
-    tests: ""
-  tasks:
-    - import_tasks: overlay-git.yml
-      when: use_git_build
-    # Next copy all of the tests/ directory
-    - name: Copy test data
-      synchronize: src=../../ dest=/root/tests/ archive=yes
-    # Down the line perhaps do each log file separately?
-    - name: Run shell script sysinstalled tests
-      shell: /root/tests/installed/run.sh &> /root/installed-tests.log
-      environment:
-        TESTS: "{{ tests }}"
-      register: sysinstalled_result
-      failed_when: False
-    - name: Fetch sysinstalled results
-      fetch:
-        src: /root/installed-tests.log
-        dest: artifacts/installed-tests.log
-        flat: yes
-    - name: Assert that sysinstalled tests succeeded
-      when: sysinstalled_result.rc != 0
-      fail:
-        msg: "sysinstalled tests failed"
index 45bf7d93aa7e32d11e64a4d9a736f2f9a5820b51..b3d14a74fa8686cd69b7277150a28486cdebeefc 100644 (file)
@@ -1,2 +1,15 @@
-This suite of tests is currently run from redhat-ci;
-they're intended to run as root.
+This directory holds tests that use the
+[Fedora Standard Test Interface](https://fedoraproject.org/wiki/CI/Standard_Test_Interface).
+
+The high level structure is that we take a qcow2 file, inject
+built RPMs into it, and then use Ansible to run tests.
+
+See `.papr.yml` for canonical usage.
+
+For local development, you should cache the qcow2 somewhere
+stable (outside of this git repo).  Also note that `../ci/build-rpms.sh`
+does *not* pick up uncommitted changes!  Stated more strongly, you
+currently need to run `build-rpms.sh` after every change.
+
+To run just a specific test, use e.g.:
+`env TEST_SUBJECTS=/path/to/qcow2 ./playbook-run.sh -e tests=.*pull nondestructive.yml`
diff --git a/tests/installed/destructive.yml b/tests/installed/destructive.yml
new file mode 100644 (file)
index 0000000..26843e7
--- /dev/null
@@ -0,0 +1,35 @@
+# This entrypoint right now just runs the sysinstalled-tests.
+---
+- hosts: localhost
+  tags:
+  - atomic
+  remote_user: root
+  vars:
+    use_git_build: True
+    tests: "."
+  tasks:
+    - import_tasks: overlay-git.yml
+      when: use_git_build
+    # Next copy all of the tests/ directory
+    - name: Copy test data
+      synchronize: src=../../ dest=/root/tests/ archive=yes
+    - find:
+        paths: /root/tests/installed/destructive
+        patterns: "itest-*.sh"
+      register: all_tests
+    - set_fact:
+        selected_tests: "{{ all_tests.files|map(attribute='path') | select('match', tests) | list }}"
+    - assert:
+        that:
+          - "{{ selected_tests|length }} != 0"
+    - file: path=/root/logs state=directory
+    - block:
+        - name: Run destructive tests
+          shell: "{{ item }} &> /root/logs/$(basename {{ item }}).log"
+          with_items:
+            - "{{ selected_tests }}"
+      always:
+        - synchronize:
+            src: /root/logs/
+            dest: artifacts/installed-destructive
+            mode: pull
diff --git a/tests/installed/destructive/README.md b/tests/installed/destructive/README.md
new file mode 100644 (file)
index 0000000..cafe605
--- /dev/null
@@ -0,0 +1,5 @@
+This suite of tests is run from PAPR. Everything in here is destructive; it's
+recommended to only run them in disposable virtual machines.  This is done
+in `tests/fedora-str/sysinstalled-tests.yml`, which currently uses a single VM
+and runs the tests serially.  It's likely in the future this will be changed
+to do one VM per test.
diff --git a/tests/installed/destructive/itest-bare-root.sh b/tests/installed/destructive/itest-bare-root.sh
new file mode 100755 (executable)
index 0000000..3a5302e
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Tests of the "raw ostree" functionality using the host's ostree repo as uid 0.
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+echo "1..2"
+date
+
+cd /ostree/repo/tmp
+rm co -rf
+rm co-testref -rf
+ostree refs --delete testref
+ostree checkout -H ${host_refspec} co
+victim_symlink=/usr/bin/gtar  # Seems likely to stick around
+# Copy the link to avoid corrupting it
+cp co/${victim_symlink}{,.tmp}
+mv co/${victim_symlink}{.tmp,}
+# Add another xattr to a symlink and a directory, since otherwise this is unusual
+setfattr -n security.biometric -v iris co/${victim_symlink}
+setfattr -n security.crunchy -v withketchup co/usr/bin
+csum=$(ostree commit -b testref --link-checkout-speedup --tree=dir=co)
+ostree fsck
+ostree ls -X testref ${victim_symlink} > ls.txt
+assert_file_has_content ls.txt 'security.biometric'
+ostree ls -X ${host_refspec} ${victim_symlink} > ls.txt
+assert_not_file_has_content ls.txt security.biometric
+ostree ls -X testref usr/bin > ls.txt
+assert_file_has_content ls.txt 'security.crunchy'
+
+ostree checkout -H testref co-testref
+getfattr -n security.biometric co-testref/${victim_symlink} > xattr.txt
+assert_file_has_content xattr.txt 'security.biometric="iris"'
+getfattr -n security.crunchy co-testref/usr/bin > xattr.txt
+assert_file_has_content xattr.txt 'security.crunchy="withketchup"'
+
+rm co -rf
+rm co-testref -rf
+
+echo "ok xattrs"
+date
diff --git a/tests/installed/destructive/itest-deploy-selinux.sh b/tests/installed/destructive/itest-deploy-selinux.sh
new file mode 100755 (executable)
index 0000000..92f6993
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Verify our /etc merge works with selinux
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+date
+# Create a new deployment
+ostree admin deploy --karg-proc-cmdline ${host_refspec}
+new_deployment_path=/ostree/deploy/${host_osname}/deploy/${host_commit}.1
+
+# Test /etc directory mtime
+if ! test ${new_deployment_path}/etc/NetworkManager -nt /etc/NetworkManager; then
+    ls -al ${new_deployment_path}/etc/NetworkManager /etc/NetworkManager
+    fatal "/etc directory mtime not newer"
+fi
+
+# A set of files that have a variety of security contexts
+for file in fstab passwd exports hostname sysctl.conf yum.repos.d \
+            NetworkManager/dispatcher.d/hook-network-manager; do
+    if ! test -e /etc/${file}; then
+        continue
+    fi
+
+    current=$(cd /etc && ls -Z ${file})
+    new=$(cd ${new_deployment_path}/etc && ls -Z ${file})
+    assert_streq "${current}" "${new}"
+done
+
+# Cleanup
+ostree admin undeploy 0
+
+cd /ostree/repo/tmp
+ostree checkout --fsync=0 -H ${host_commit} test-label
+rm test-label/usr/lib/ostree-boot/vmlinuz*
+rm test-label/usr/lib/ostree-boot/initramfs*
+cd test-label/usr/lib/modules/*
+rm initramfs.img
+echo new initramfs > initramfs.img
+cd -
+ostree commit --link-checkout-speedup --selinux-policy=test-label -b test-label --consume --tree=dir=test-label
+
+ostree admin deploy --karg-proc-cmdline test-label
+
+# This captures all of the boot entries; it'd be slightly annoying
+# to try to figure out the accurate one, so let's just ensure that at least
+# one entry is boot_t.
+# https://bugzilla.redhat.com/show_bug.cgi?id=1536991
+ls -Z /boot/ostree/*/ > bootlsz.txt
+assert_file_has_content_literal bootlsz.txt 'system_u:object_r:boot_t:s0 vmlinuz-'
+assert_file_has_content_literal bootlsz.txt 'system_u:object_r:boot_t:s0 initramfs-'
+
+ostree admin undeploy 0
+ostree refs --delete test-label
+date
diff --git a/tests/installed/destructive/itest-label-selinux.sh b/tests/installed/destructive/itest-label-selinux.sh
new file mode 100755 (executable)
index 0000000..2a49285
--- /dev/null
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+# Test commit --selinux-policy
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+date
+cd /ostree/repo/tmp
+rm co -rf
+ostree checkout -H ${host_refspec} co
+testbin=co/usr/bin/foo-a-generic-binary
+assert_not_has_file "${testbin}"
+# Make a test binary that we label as shell_exec_t on disk, but should be
+# reset by --selinux-policy back to bin_t
+echo 'test foo' > ${testbin}
+chcon --reference co/usr/bin/true ${testbin}
+oldcon=$(getfattr --only-values -m security.selinux ${testbin})
+chcon --reference co/usr/bin/bash ${testbin}
+newcon=$(getfattr --only-values -m security.selinux ${testbin})
+assert_not_streq "${oldcon}" "${newcon}"
+ostree commit -b testbranch --link-checkout-speedup \
+       --selinux-policy co --tree=dir=co
+ostree ls -X testbranch /usr/bin/foo-a-generic-binary > ls.txt
+assert_file_has_content ls.txt ${oldcon}
+ostree fsck
+
+ostree refs --delete testbranch
+rm co -rf
+echo "ok commit with sepolicy"
+
+# Now let's check that selinux policy labels can be applied on checkout
+
+rm rootfs -rf
+if ostree checkout -H \
+    --selinux-policy / ${host_refspec} co; then
+  assert_not_reached "checked out with -H and --selinux-policy"
+fi
+# recommit just two binaries into a new branch with selinux labels stripped
+mkdir -p rootfs/usr/bin
+oldcon=$(getfattr --only-values -m security.selinux /usr/bin/bash)
+cp /usr/bin/{true,bash} rootfs/usr/bin
+newcon=$(getfattr --only-values -m security.selinux rootfs/usr/bin/bash)
+assert_not_streq "${oldcon}" "${newcon}"
+echo "ok checkout with sepolicy setup"
+
+ostree commit -b testbranch rootfs
+ostree checkout testbranch --selinux-policy / co
+newcon=$(getfattr --only-values -m security.selinux co/usr/bin/bash)
+assert_streq "${oldcon}" "${newcon}"
+rm co -rf
+echo "ok checkout with sepolicy"
+ostree checkout testbranch --selinux-policy / --subpath /usr/bin co
+newcon=$(getfattr --only-values -m security.selinux co/bash)
+assert_streq "${oldcon}" "${newcon}"
+rm co -rf
+echo "ok checkout with sepolicy and subpath"
+
+# now commit tree with mismatched leading dirs
+mkdir -p rootfs/subdir
+mv rootfs/{usr,subdir}
+ostree commit -b testbranch rootfs
+ostree checkout testbranch --selinux-policy / co
+newcon=$(getfattr --only-values -m security.selinux co/subdir/usr/bin/bash)
+assert_not_streq "${oldcon}" "${newcon}"
+rm co -rf
+ostree checkout testbranch --selinux-policy / \
+  --subpath subdir --selinux-prefix / co
+newcon=$(getfattr --only-values -m security.selinux co/usr/bin/bash)
+assert_streq "${oldcon}" "${newcon}"
+rm co -rf
+echo "ok checkout with sepolicy and selinux-prefix"
+
+# Now check that combining --selinux-policy with --skip-list doesn't blow up
+echo > skip-list.txt << EOF
+/usr/bin/true
+EOF
+ostree checkout testbranch --selinux-policy / --skip-list skip-list.txt \
+  --subpath subdir --selinux-prefix / co
+! test -f co/usr/bin/true
+test -f co/usr/bin/bash
+newcon=$(getfattr --only-values -m security.selinux co/usr/bin/bash)
+assert_streq "${oldcon}" "${newcon}"
+rm co -rf
+ostree refs --delete testbranch
+echo "ok checkout selinux and skip-list"
+date
diff --git a/tests/installed/execute_batch.yml b/tests/installed/execute_batch.yml
new file mode 100644 (file)
index 0000000..7fd8374
--- /dev/null
@@ -0,0 +1,22 @@
+#####################
+# execute_batch.yml
+#####################
+- name: Begin async command execution
+  shell: "{{ async_item }} &> {{ logdir }}/{{ async_item|basename }}.log"
+  # 10 minutes; the PAPR tester generally times out before that
+  async: 600
+  poll: 0
+  with_items: "{{ async_commands }}"
+  loop_control:
+    loop_var: "async_item"
+  register: async_results
+
+- name: Check async command status
+  async_status:
+    jid: "{{ async_result_item.ansible_job_id }}"
+  with_items: "{{ async_results.results }}"
+  loop_control:
+    loop_var: "async_result_item"
+  register: async_poll_results
+  until: async_poll_results.finished
+  retries: 240
diff --git a/tests/installed/itest-bare-root.sh b/tests/installed/itest-bare-root.sh
deleted file mode 100755 (executable)
index 0d384c2..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-# Tests of the "raw ostree" functionality using the host's ostree repo as uid 0.
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-echo "1..2"
-
-cd /ostree/repo/tmp
-rm co -rf
-rm co-testref -rf
-ostree refs --delete testref
-ostree checkout -H ${host_refspec} co
-victim_symlink=/usr/bin/gtar  # Seems likely to stick around
-# Copy the link to avoid corrupting it
-cp co/${victim_symlink}{,.tmp}
-mv co/${victim_symlink}{.tmp,}
-# Add another xattr to a symlink and a directory, since otherwise this is unusual
-setfattr -n security.biometric -v iris co/${victim_symlink}
-setfattr -n security.crunchy -v withketchup co/usr/bin
-csum=$(ostree commit -b testref --link-checkout-speedup --tree=dir=co)
-ostree fsck
-ostree ls -X testref ${victim_symlink} > ls.txt
-assert_file_has_content ls.txt 'security.biometric'
-ostree ls -X ${host_refspec} ${victim_symlink} > ls.txt
-assert_not_file_has_content ls.txt security.biometric
-ostree ls -X testref usr/bin > ls.txt
-assert_file_has_content ls.txt 'security.crunchy'
-
-ostree checkout -H testref co-testref
-getfattr -n security.biometric co-testref/${victim_symlink} > xattr.txt
-assert_file_has_content xattr.txt 'security.biometric="iris"'
-getfattr -n security.crunchy co-testref/usr/bin > xattr.txt
-assert_file_has_content xattr.txt 'security.crunchy="withketchup"'
-
-rm co -rf
-rm co-testref -rf
-
-echo "ok xattrs"
diff --git a/tests/installed/itest-bare-unit.sh b/tests/installed/itest-bare-unit.sh
deleted file mode 100755 (executable)
index fe07f24..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-# Run test-basic.sh as root.
-# https://github.com/ostreedev/ostree/pull/1199
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-# These tests sort of bypass the installed-tests spec;
-# fixing that would require installing g-d-t-r, though
-# more ideally we architect things with a "control" container
-# distinct from the host.
-export G_TEST_SRCDIR=$(realpath $dn/../..)
-
-# Use /var/tmp to hopefully use XFS + O_TMPFILE etc.
-prepare_tmpdir /var/tmp
-trap _tmpdir_cleanup EXIT
-/usr/libexec/installed-tests/libostree/test-basic.sh
-/usr/libexec/installed-tests/libostree/test-basic-c
diff --git a/tests/installed/itest-bare-user-root.sh b/tests/installed/itest-bare-user-root.sh
deleted file mode 100755 (executable)
index f5feac9..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-# Tests of the "raw ostree" functionality using the host's ostree repo as uid 0.
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-echo "1..1"
-
-prepare_tmpdir
-ostree --repo=repo init --mode=bare-user
-mkdir -p components/{dbus,systemd}/usr/{bin,lib}
-echo dbus binary > components/dbus/usr/bin/dbus-daemon
-chmod a+x components/dbus/usr/bin/dbus-daemon
-echo dbus lib > components/dbus/usr/lib/libdbus.so.1
-echo dbus helper > components/dbus/usr/lib/dbus-daemon-helper
-chmod a+x components/dbus/usr/lib/dbus-daemon-helper
-echo systemd binary > components/systemd/usr/bin/systemd
-chmod a+x components/systemd/usr/bin/systemd
-echo systemd lib > components/systemd/usr/lib/libsystemd.so.1
-
-# Make the gid on dbus 81 like fedora, also ensure no xattrs
-ostree --repo=repo commit --no-xattrs -b component-dbus --owner-uid 0 --owner-gid 81 --tree=dir=components/dbus
-ostree --repo=repo commit --no-xattrs -b component-systemd --owner-uid 0 --owner-gid 0 --tree=dir=components/systemd
-rm rootfs -rf
-for component in dbus systemd; do
-    ostree --repo=repo checkout -U -H component-${component} --union rootfs
-done
-echo 'some rootfs data' > rootfs/usr/lib/cache.txt
-# Commit using the host's selinux policy
-ostree --repo=repo commit --selinux-policy / -b rootfs --link-checkout-speedup --tree=dir=rootfs
-ostree --repo=repo ls rootfs /usr/bin/systemd >ls.txt
-assert_file_has_content ls.txt '^-007.. 0 0 .*/usr/bin/systemd'
-ostree --repo=repo ls -X rootfs /usr/lib/dbus-daemon-helper >ls.txt
-assert_file_has_content ls.txt '^-007.. 0 81 .*security.selinux.*/usr/lib/dbus-daemon-helper'
-assert_not_file_has_content ls.txt 'user.ostreemeta'
-echo "ok bare-user link-checkout-speedup with modified xattrs maintains uids"
diff --git a/tests/installed/itest-bareuser-nouserxattrs.sh b/tests/installed/itest-bareuser-nouserxattrs.sh
deleted file mode 100755 (executable)
index c8c0794..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-# Test that initializing a bare-user repo on tmpfs fails
-# Maybe at some point this will be fixed in the kernel
-# but I doubt it'll be soon
-# https://www.spinics.net/lists/linux-mm/msg109775.html
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-prepare_tmpdir
-trap _tmpdir_cleanup EXIT
-
-mkdir mnt
-mount -t tmpfs tmpfs mnt
-if ostree --repo=mnt/repo init --mode=bare-user 2>err.txt; then
-    umount mnt
-    assert_not_reached "bare-user on tmpfs worked?"
-fi
-umount mnt
-assert_file_has_content err.txt "Operation not supported"
diff --git a/tests/installed/itest-deploy-selinux.sh b/tests/installed/itest-deploy-selinux.sh
deleted file mode 100755 (executable)
index 2ad34c3..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-# Verify our /etc merge works with selinux
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-# Create a new deployment
-ostree admin deploy --karg-proc-cmdline ${host_refspec}
-new_deployment_path=/ostree/deploy/${host_osname}/deploy/${host_commit}.1
-
-# Test /etc directory mtime
-if ! test ${new_deployment_path}/etc/NetworkManager -nt /etc/NetworkManager; then
-    ls -al ${new_deployment_path}/etc/NetworkManager /etc/NetworkManager
-    fatal "/etc directory mtime not newer"
-fi
-
-# A set of files that have a variety of security contexts
-for file in fstab passwd exports hostname sysctl.conf yum.repos.d \
-            NetworkManager/dispatcher.d/hook-network-manager; do
-    if ! test -e /etc/${file}; then
-        continue
-    fi
-
-    current=$(cd /etc && ls -Z ${file})
-    new=$(cd ${new_deployment_path}/etc && ls -Z ${file})
-    assert_streq "${current}" "${new}"
-done
-
-# Cleanup
-ostree admin undeploy 0
-
-cd /ostree/repo/tmp
-ostree checkout --fsync=0 -H ${host_commit} test-label
-rm test-label/usr/lib/ostree-boot/vmlinuz*
-rm test-label/usr/lib/ostree-boot/initramfs*
-cd test-label/usr/lib/modules/*
-rm initramfs.img
-echo new initramfs > initramfs.img
-cd -
-ostree commit --link-checkout-speedup --selinux-policy=test-label -b test-label --consume --tree=dir=test-label
-
-ostree admin deploy --karg-proc-cmdline test-label
-
-# This captures all of the boot entries; it'd be slightly annoying
-# to try to figure out the accurate one, so let's just ensure that at least
-# one entry is boot_t.
-# https://bugzilla.redhat.com/show_bug.cgi?id=1536991
-ls -Z /boot/ostree/*/ > bootlsz.txt
-assert_file_has_content_literal bootlsz.txt 'system_u:object_r:boot_t:s0 vmlinuz-'
-assert_file_has_content_literal bootlsz.txt 'system_u:object_r:boot_t:s0 initramfs-'
-
-ostree admin undeploy 0
-ostree refs --delete test-label
diff --git a/tests/installed/itest-label-selinux.sh b/tests/installed/itest-label-selinux.sh
deleted file mode 100755 (executable)
index 463887a..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-
-# Test commit --selinux-policy
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-cd /ostree/repo/tmp
-rm co -rf
-ostree checkout -H ${host_refspec} co
-testbin=co/usr/bin/foo-a-generic-binary
-assert_not_has_file "${testbin}"
-# Make a test binary that we label as shell_exec_t on disk, but should be
-# reset by --selinux-policy back to bin_t
-echo 'test foo' > ${testbin}
-chcon --reference co/usr/bin/true ${testbin}
-oldcon=$(getfattr --only-values -m security.selinux ${testbin})
-chcon --reference co/usr/bin/bash ${testbin}
-newcon=$(getfattr --only-values -m security.selinux ${testbin})
-assert_not_streq "${oldcon}" "${newcon}"
-ostree commit -b testbranch --link-checkout-speedup \
-       --selinux-policy co --tree=dir=co
-ostree ls -X testbranch /usr/bin/foo-a-generic-binary > ls.txt
-assert_file_has_content ls.txt ${oldcon}
-ostree fsck
-
-ostree refs --delete testbranch
-rm co -rf
-echo "ok commit with sepolicy"
-
-# Now let's check that selinux policy labels can be applied on checkout
-
-rm rootfs -rf
-if ostree checkout -H \
-    --selinux-policy / ${host_refspec} co; then
-  assert_not_reached "checked out with -H and --selinux-policy"
-fi
-# recommit just two binaries into a new branch with selinux labels stripped
-mkdir -p rootfs/usr/bin
-oldcon=$(getfattr --only-values -m security.selinux /usr/bin/bash)
-cp /usr/bin/{true,bash} rootfs/usr/bin
-newcon=$(getfattr --only-values -m security.selinux rootfs/usr/bin/bash)
-assert_not_streq "${oldcon}" "${newcon}"
-echo "ok checkout with sepolicy setup"
-
-ostree commit -b testbranch rootfs
-ostree checkout testbranch --selinux-policy / co
-newcon=$(getfattr --only-values -m security.selinux co/usr/bin/bash)
-assert_streq "${oldcon}" "${newcon}"
-rm co -rf
-echo "ok checkout with sepolicy"
-ostree checkout testbranch --selinux-policy / --subpath /usr/bin co
-newcon=$(getfattr --only-values -m security.selinux co/bash)
-assert_streq "${oldcon}" "${newcon}"
-rm co -rf
-echo "ok checkout with sepolicy and subpath"
-
-# now commit tree with mismatched leading dirs
-mkdir -p rootfs/subdir
-mv rootfs/{usr,subdir}
-ostree commit -b testbranch rootfs
-ostree checkout testbranch --selinux-policy / co
-newcon=$(getfattr --only-values -m security.selinux co/subdir/usr/bin/bash)
-assert_not_streq "${oldcon}" "${newcon}"
-rm co -rf
-ostree checkout testbranch --selinux-policy / \
-  --subpath subdir --selinux-prefix / co
-newcon=$(getfattr --only-values -m security.selinux co/usr/bin/bash)
-assert_streq "${oldcon}" "${newcon}"
-rm co -rf
-echo "ok checkout with sepolicy and selinux-prefix"
-
-# Now check that combining --selinux-policy with --skip-list doesn't blow up
-echo > skip-list.txt << EOF
-/usr/bin/true
-EOF
-ostree checkout testbranch --selinux-policy / --skip-list skip-list.txt \
-  --subpath subdir --selinux-prefix / co
-! test -f co/usr/bin/true
-test -f co/usr/bin/bash
-newcon=$(getfattr --only-values -m security.selinux co/usr/bin/bash)
-assert_streq "${oldcon}" "${newcon}"
-rm co -rf
-ostree refs --delete testbranch
-echo "ok checkout selinux and skip-list"
diff --git a/tests/installed/itest-payload-link.sh b/tests/installed/itest-payload-link.sh
deleted file mode 100755 (executable)
index f0576d8..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2018 Red Hat, Inc.
-#
-# SPDX-License-Identifier: LGPL-2.0+
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-echo "1..1"
-
-# Use /var/tmp so we have O_TMPFILE etc.
-prepare_tmpdir /var/tmp
-trap _tmpdir_cleanup EXIT
-ostree --repo=repo init --mode=archive
-echo -e '[archive]\nzlib-level=1\n' >> repo/config
-
-mkdir content
-cd content
-dd if=/dev/urandom of=bigobject bs=4k count=2560
-cp --reflink=auto bigobject bigobject2
-# Different metadata, same content
-chown bin:bin bigobject2
-cd ..
-ostree --repo=repo commit -b dupobjects --consume --selinux-policy=/ --tree=dir=content
-ostree --repo=repo summary -u
-
-run_tmp_webserver $(pwd)/repo
-
-origin=$(cat ${test_tmpdir}/httpd-address)
-
-cleanup() {
-    cd ${test_tmpdir}
-    umount mnt || true
-    test -n "${blkdev:-}" && losetup -d ${blkdev} || true
-}
-trap cleanup EXIT
-
-mkdir mnt
-truncate -s 2G testblk.img
-if ! blkdev=$(losetup --find --show $(pwd)/testblk.img); then
-    echo "ok # SKIP not run when cannot setup loop device"
-    exit 0
-fi
-
-# This filesystem must support reflinks
-mkfs.xfs -m reflink=1 ${blkdev}
-
-mount ${blkdev} mnt
-cd mnt
-
-# Test that reflink is really there (not just --reflink=auto)
-touch a
-cp --reflink a b
-mkdir repo
-ostree --repo=repo init
-ostree config --repo=repo set core.payload-link-threshold 0
-ostree --repo=repo remote add origin --set=gpg-verify=false ${origin}
-ostree --repo=repo pull --disable-static-deltas origin dupobjects
-find repo -type l -name '*.payload-link' >payload-links.txt
-assert_streq "$(wc -l < payload-links.txt)" "1"
-
-# Disable logging for inner loop
-set +x
-cat payload-links.txt | while read i; do
-    payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link)
-    payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1)
-    assert_streq "${payload_checksum}" "${payload_checksum_calculated}"
-done
-set -x
-echo "ok pull creates .payload-link"
diff --git a/tests/installed/itest-pull-space.sh b/tests/installed/itest-pull-space.sh
deleted file mode 100755 (executable)
index 8d218b1..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-# Test min-free-space-percent using loopback devices
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-prepare_tmpdir
-trap _tmpdir_cleanup EXIT
-
-cd ${test_tmpdir}
-truncate -s 100MB testblk.img
-blkdev=$(losetup --find --show $(pwd)/testblk.img)
-mkfs.xfs ${blkdev}
-mkdir mnt
-mount ${blkdev} mnt
-ostree --repo=mnt/repo init --mode=bare-user
-if ostree --repo=mnt/repo pull-local /ostree/repo ${host_commit} 2>err.txt; then
-    fatal "succeeded in doing a pull with no free space"
-fi
-assert_file_has_content err.txt "min-free-space-percent"
-umount mnt
-losetup -d ${blkdev}
diff --git a/tests/installed/itest-pull.sh b/tests/installed/itest-pull.sh
deleted file mode 100755 (executable)
index b80acdb..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-# Using the host ostree, test HTTP pulls
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-prepare_tmpdir /var/tmp
-trap _tmpdir_cleanup EXIT
-
-# Take the host's ostree, and make it archive
-mkdir repo
-ostree --repo=repo init --mode=archive
-echo -e '[archive]\nzlib-level=1\n' >> repo/config
-host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,')
-ostree --repo=repo pull-local /ostree/repo ${host_commit}
-ostree --repo=repo refs ${host_commit} --create=${host_nonremoteref}
-
-run_tmp_webserver $(pwd)/repo
-# Now test pulling via HTTP (no deltas) to a new bare-user repo
-ostree --repo=bare-repo init --mode=bare-user
-ostree --repo=bare-repo remote add origin --set=gpg-verify=false $(cat ${test_tmpdir}/httpd-address)
-ostree --repo=bare-repo pull --disable-static-deltas origin ${host_nonremoteref}
-
-rm bare-repo repo -rf
-
-# Try copying the host's repo across a mountpoint for direct
-# imports.
-cd ${test_tmpdir}
-mkdir tmpfs mnt
-mount --bind tmpfs mnt
-cd mnt
-ostree --repo=repo init --mode=bare
-ostree --repo=repo pull-local /ostree/repo ${host_commit}
-ostree --repo=repo fsck
-cd ..
-umount mnt
diff --git a/tests/installed/itest-remotes.sh b/tests/installed/itest-remotes.sh
deleted file mode 100755 (executable)
index 8a79015..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-# Test that we didn't regress /etc/ostree/remotes.d handling
-
-set -xeuo pipefail
-
-dn=$(dirname $0)
-. ${dn}/libinsttest.sh
-
-prepare_tmpdir
-trap _tmpdir_cleanup EXIT
-
-ostree remote list > remotes.txt
-if ! test -s remotes.txt; then
-    assert_not_reached "no ostree remotes"
-fi
index 96da9545479955a5ecd4f1952aed370886f7bd34..4968adc0e374cdea521e23b2ada8e6dfc3426752 100644 (file)
@@ -20,7 +20,7 @@
 # Boston, MA 02111-1307, USA.
 
 dn=$(dirname $0)
-. ${dn}/libtest-core.sh
+. ${dn}/../libtest-core.sh
 
 # Copy of bits from tap-test
 test_tmpdir=
diff --git a/tests/installed/nondestructive.yml b/tests/installed/nondestructive.yml
new file mode 100644 (file)
index 0000000..88a6487
--- /dev/null
@@ -0,0 +1,40 @@
+# Nondestructive sysinstalled tests, run in parallel.
+---
+- hosts: localhost
+  tags:
+  - atomic
+  remote_user: root
+  vars:
+    use_git_build: True
+    tests: "."
+    # Arbitrary...we want some parallelism
+    batching_factor: 4
+  tasks:
+    - import_tasks: overlay-git.yml
+      when: use_git_build
+    # Next copy all of the tests/ directory
+    - name: Copy test data
+      synchronize: src=../../ dest=/root/tests/ archive=yes
+    - find:
+        paths: /root/tests/installed/nondestructive
+        patterns: "itest-*.sh"
+      register: all_tests
+    - set_fact:
+        selected_tests: "{{ all_tests.files|map(attribute='path') | select('match', tests) | list }}"
+    - assert:
+        that:
+          - "{{ selected_tests|length }} != 0"
+    - file: path=/root/logs state=directory
+    - block:
+        - name: Run nondestructive tests
+          vars:
+            logdir: /root/logs
+          async_commands: "{{ item }}"
+          include_tasks: execute_batch.yml
+          with_items:
+            - "{{ selected_tests | batch('{{ batching_factor }}') | list }}"
+      always:
+        - synchronize:
+            src: /root/logs
+            dest: artifacts/installed-nondestructive
+            mode: pull
diff --git a/tests/installed/nondestructive/itest-bare-unit.sh b/tests/installed/nondestructive/itest-bare-unit.sh
new file mode 100755 (executable)
index 0000000..e331260
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Run test-basic.sh as root.
+# https://github.com/ostreedev/ostree/pull/1199
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+date
+# These tests sort of bypass the installed-tests spec;
+# fixing that would require installing g-d-t-r, though
+# more ideally we architect things with a "control" container
+# distinct from the host.
+export G_TEST_SRCDIR=$(realpath $dn/../../..)
+
+# Use /var/tmp to hopefully use XFS + O_TMPFILE etc.
+prepare_tmpdir /var/tmp
+trap _tmpdir_cleanup EXIT
+/usr/libexec/installed-tests/libostree/test-basic.sh
+/usr/libexec/installed-tests/libostree/test-basic-c
+date
diff --git a/tests/installed/nondestructive/itest-bare-user-root.sh b/tests/installed/nondestructive/itest-bare-user-root.sh
new file mode 100755 (executable)
index 0000000..4072238
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Tests of the "raw ostree" functionality using the host's ostree repo as uid 0.
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+echo "1..1"
+date
+
+prepare_tmpdir
+ostree --repo=repo init --mode=bare-user
+mkdir -p components/{dbus,systemd}/usr/{bin,lib}
+echo dbus binary > components/dbus/usr/bin/dbus-daemon
+chmod a+x components/dbus/usr/bin/dbus-daemon
+echo dbus lib > components/dbus/usr/lib/libdbus.so.1
+echo dbus helper > components/dbus/usr/lib/dbus-daemon-helper
+chmod a+x components/dbus/usr/lib/dbus-daemon-helper
+echo systemd binary > components/systemd/usr/bin/systemd
+chmod a+x components/systemd/usr/bin/systemd
+echo systemd lib > components/systemd/usr/lib/libsystemd.so.1
+
+# Make the gid on dbus 81 like fedora, also ensure no xattrs
+ostree --repo=repo commit --no-xattrs -b component-dbus --owner-uid 0 --owner-gid 81 --tree=dir=components/dbus
+ostree --repo=repo commit --no-xattrs -b component-systemd --owner-uid 0 --owner-gid 0 --tree=dir=components/systemd
+rm rootfs -rf
+for component in dbus systemd; do
+    ostree --repo=repo checkout -U -H component-${component} --union rootfs
+done
+echo 'some rootfs data' > rootfs/usr/lib/cache.txt
+# Commit using the host's selinux policy
+ostree --repo=repo commit --selinux-policy / -b rootfs --link-checkout-speedup --tree=dir=rootfs
+ostree --repo=repo ls rootfs /usr/bin/systemd >ls.txt
+assert_file_has_content ls.txt '^-007.. 0 0 .*/usr/bin/systemd'
+ostree --repo=repo ls -X rootfs /usr/lib/dbus-daemon-helper >ls.txt
+assert_file_has_content ls.txt '^-007.. 0 81 .*security.selinux.*/usr/lib/dbus-daemon-helper'
+assert_not_file_has_content ls.txt 'user.ostreemeta'
+echo "ok bare-user link-checkout-speedup with modified xattrs maintains uids"
+date
diff --git a/tests/installed/nondestructive/itest-bareuser-nouserxattrs.sh b/tests/installed/nondestructive/itest-bareuser-nouserxattrs.sh
new file mode 100755 (executable)
index 0000000..7063286
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Test that initializing a bare-user repo on tmpfs fails
+# Maybe at some point this will be fixed in the kernel
+# but I doubt it'll be soon
+# https://www.spinics.net/lists/linux-mm/msg109775.html
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+prepare_tmpdir
+trap _tmpdir_cleanup EXIT
+date
+
+mkdir mnt
+mount -t tmpfs tmpfs mnt
+if ostree --repo=mnt/repo init --mode=bare-user 2>err.txt; then
+    umount mnt
+    assert_not_reached "bare-user on tmpfs worked?"
+fi
+umount mnt
+assert_file_has_content err.txt "Operation not supported"
+date
diff --git a/tests/installed/nondestructive/itest-payload-link.sh b/tests/installed/nondestructive/itest-payload-link.sh
new file mode 100755 (executable)
index 0000000..62b8466
--- /dev/null
@@ -0,0 +1,90 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 Red Hat, Inc.
+#
+# SPDX-License-Identifier: LGPL-2.0+
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+
+echo "1..1"
+date
+
+# Use /var/tmp so we have O_TMPFILE etc.
+prepare_tmpdir /var/tmp
+trap _tmpdir_cleanup EXIT
+ostree --repo=repo init --mode=archive
+echo -e '[archive]\nzlib-level=1\n' >> repo/config
+
+mkdir content
+cd content
+dd if=/dev/urandom of=bigobject bs=4k count=2560
+cp --reflink=auto bigobject bigobject2
+# Different metadata, same content
+chown bin:bin bigobject2
+cd ..
+ostree --repo=repo commit -b dupobjects --consume --selinux-policy=/ --tree=dir=content
+ostree --repo=repo summary -u
+
+run_tmp_webserver $(pwd)/repo
+
+origin=$(cat ${test_tmpdir}/httpd-address)
+
+cleanup() {
+    cd ${test_tmpdir}
+    umount mnt || true
+    test -n "${blkdev:-}" && losetup -d ${blkdev} || true
+}
+trap cleanup EXIT
+
+mkdir mnt
+truncate -s 2G testblk.img
+if ! blkdev=$(losetup --find --show $(pwd)/testblk.img); then
+    echo "ok # SKIP not run when cannot setup loop device"
+    exit 0
+fi
+
+# This filesystem must support reflinks
+mkfs.xfs -m reflink=1 ${blkdev}
+
+mount ${blkdev} mnt
+cd mnt
+
+# Test that reflink is really there (not just --reflink=auto)
+touch a
+cp --reflink a b
+mkdir repo
+ostree --repo=repo init
+ostree config --repo=repo set core.payload-link-threshold 0
+ostree --repo=repo remote add origin --set=gpg-verify=false ${origin}
+ostree --repo=repo pull --disable-static-deltas origin dupobjects
+find repo -type l -name '*.payload-link' >payload-links.txt
+assert_streq "$(wc -l < payload-links.txt)" "1"
+
+# Disable logging for inner loop
+set +x
+cat payload-links.txt | while read i; do
+    payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link)
+    payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1)
+    assert_streq "${payload_checksum}" "${payload_checksum_calculated}"
+done
+set -x
+echo "ok pull creates .payload-link"
+date
diff --git a/tests/installed/nondestructive/itest-pull-space.sh b/tests/installed/nondestructive/itest-pull-space.sh
new file mode 100755 (executable)
index 0000000..925629b
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Test min-free-space-percent using loopback devices
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+date
+
+prepare_tmpdir
+trap _tmpdir_cleanup EXIT
+
+cd ${test_tmpdir}
+truncate -s 20MB testblk.img
+blkdev=$(losetup --find --show $(pwd)/testblk.img)
+mkfs.xfs ${blkdev}
+mkdir mnt
+mount ${blkdev} mnt
+ostree --repo=mnt/repo init --mode=bare-user
+echo 'fsync=false' >> mnt/repo/config
+if ostree --repo=mnt/repo pull-local /ostree/repo ${host_commit} 2>err.txt; then
+    fatal "succeeded in doing a pull with no free space"
+fi
+assert_file_has_content err.txt "min-free-space-percent"
+umount mnt
+losetup -d ${blkdev}
+date
diff --git a/tests/installed/nondestructive/itest-pull.sh b/tests/installed/nondestructive/itest-pull.sh
new file mode 100755 (executable)
index 0000000..a7cd922
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# Using the host ostree, test HTTP pulls
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+date
+
+prepare_tmpdir /var/tmp
+trap _tmpdir_cleanup EXIT
+
+# Take the host's ostree, and make it archive
+mkdir repo
+ostree --repo=repo init --mode=archive
+echo -e '[archive]\nzlib-level=1\n' >> repo/config
+host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,')
+log_timestamps() {
+    date
+    "$@"
+    date
+}
+log_timestamps ostree --repo=repo pull-local /ostree/repo ${host_commit}
+ostree --repo=repo refs ${host_commit} --create=${host_nonremoteref}
+
+run_tmp_webserver $(pwd)/repo
+# Now test pulling via HTTP (no deltas) to a new bare-user repo
+ostree --repo=bare-repo init --mode=bare-user
+ostree --repo=bare-repo remote add origin --set=gpg-verify=false $(cat ${test_tmpdir}/httpd-address)
+log_timestamps ostree --repo=bare-repo pull --disable-static-deltas origin ${host_nonremoteref}
+
+rm bare-repo repo -rf
+
+# Try copying the host's repo across a mountpoint for direct
+# imports.
+cd ${test_tmpdir}
+mkdir tmpfs mnt
+mount --bind tmpfs mnt
+cd mnt
+ostree --repo=repo init --mode=bare
+log_timestamps ostree --repo=repo pull-local /ostree/repo ${host_commit}
+log_timestamps ostree --repo=repo fsck
+cd ..
+umount mnt
+
+kill -TERM $(cat ${test_tmpdir}/httpd-pid)
+echo "ok"
+date
diff --git a/tests/installed/nondestructive/itest-remotes.sh b/tests/installed/nondestructive/itest-remotes.sh
new file mode 100755 (executable)
index 0000000..836e35a
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Test that we didn't regress /etc/ostree/remotes.d handling
+
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../libinsttest.sh
+date
+
+prepare_tmpdir
+trap _tmpdir_cleanup EXIT
+
+ostree remote list > remotes.txt
+if ! test -s remotes.txt; then
+    assert_not_reached "no ostree remotes"
+fi
+date
diff --git a/tests/installed/nondestructive/libtest-core.sh b/tests/installed/nondestructive/libtest-core.sh
new file mode 120000 (symlink)
index 0000000..d26203e
--- /dev/null
@@ -0,0 +1 @@
+../libtest-core.sh
\ No newline at end of file
diff --git a/tests/installed/overlay-git.yml b/tests/installed/overlay-git.yml
new file mode 100644 (file)
index 0000000..0018a1b
--- /dev/null
@@ -0,0 +1,23 @@
+# Run "admin unlock" and add locally built RPMs, then
+# copy the whole tests/ directory into the VM.
+- command: ostree --version
+  changed_when: False
+  register: ostree_orig_version
+- set_fact:
+    ostree_orig_version_yaml: "{{ ostree_orig_version.stdout | from_yaml }}"
+- name: Copy locally built RPMs
+  synchronize: src=build/x86_64/ dest=/root/x86_64/ archive=yes
+- shell: ostree admin unlock || true
+# Install the RPMs we already have.  For the test suite we use rpm2cpio
+# since it depends on libsoup, but we're not using that yet for the sysinstalled tests
+- shell: >
+    /usr/bin/rpm -Fvh /root/x86_64/*.rpm && \
+    cd / && rpm2cpio /root/x86_64/ostree-tests-2*.rpm | cpio -div
+- command: ostree --version
+  register: ostree_new_version
+- set_fact:
+    ostree_new_version_yaml: "{{ ostree_new_version.stdout | from_yaml }}"
+- name: "Fail if we didn't change the ostree version"
+  when: ostree_orig_version_yaml['libostree']['Git'] == ostree_new_version_yaml['libostree']['Git']
+  fail:
+    msg: "Failed to change ostree version"
diff --git a/tests/installed/playbook-run.sh b/tests/installed/playbook-run.sh
new file mode 100755 (executable)
index 0000000..c188729
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/bash
+# A thin wrapper for ansible-playbook which has a nice check for
+# TEST_SUBJECTS being set.
+set -xeuo pipefail
+
+# https://fedoraproject.org/wiki/CI/Tests
+if test -z "${TEST_SUBJECTS:-}"; then
+    cat <<EOF
+
+error: TEST_SUBJECTS must be set; e.g.:
+
+  curl -Lo fedora-atomic-host.qcow2 'https://getfedora.org/atomic_qcow2_latest'
+  export TEST_SUBJECTS=\$(pwd)/fedora-atomic-host.qcow2
+
+If you're doing interactive development, we recommend caching the qcow2
+somewhere persistent.
+EOF
+    exit 1
+fi
+for subj in ${TEST_SUBJECTS}; do
+    ls -al ${subj} && file ${subj}
+done
+
+# This is required
+rpm -q standard-test-roles
+
+export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)}
+ls -al /dev/kvm
+exec ansible-playbook --tags=atomic "$@"
diff --git a/tests/installed/provision.sh b/tests/installed/provision.sh
new file mode 100755 (executable)
index 0000000..3a1efe9
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/bash
+set -xeuo pipefail
+
+dn=$(dirname $0)
+. ${dn}/../../ci/libpaprci/libbuild.sh
+
+pkg_upgrade
+pkg_install git rsync openssh-clients ansible standard-test-roles
+
+# "Hot patch" this to pick up https://pagure.io/standard-test-roles/pull-request/152
+# so we get parallelism
+cd /usr/share/ansible/inventory && curl -L -O https://pagure.io/standard-test-roles/raw/master/f/inventory/standard-inventory-qcow2
index 8c7fe4d85e09ab0816fbd8d4155e014479384590..497777a7bb8ed585fb24248864e4d3c2dd432021 100755 (executable)
@@ -1,17 +1,17 @@
-#!/bin/bash
-
+#!/usr/bin/bash
+# Run all installed tests; see README.md in this directory for more
+# information.
 set -xeuo pipefail
 
-dn=$(dirname $0)
-for tn in ${dn}/itest-*.sh; do
-    if [ -n "${TESTS:-}" ]; then
-      tbn=$(basename "$tn" .sh)
-      tbn=" ${tbn#itest-} "
-      if [[ " $TESTS " != *$tbn* ]]; then
-        echo "Skipping: ${tn}"
-        continue
-      fi
-    fi
-    echo Executing: ${tn}
-    ${tn}
+dn=$(cd $(dirname $0) && pwd)
+
+if ! test -d build; then
+    mkdir -p build
+    (cd build && ${dn}/../../ci/build-rpm.sh)
+fi
+
+# TODO: parallelize this
+PLAYBOOKS=${PLAYBOOKS:-nondestructive.yml destructive.yml}
+for playbook in $PLAYBOOKS; do
+    time ${dn}/playbook-run.sh -v ${dn}/${playbook}
 done